package com.wht.sip.core.transmit.message;

import com.wht.sip.core.context.SipProcessorContext;
import gov.nist.javax.sip.message.SIPRequest;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.annotation.Init;
import org.noear.solon.annotation.Managed;

import javax.sip.RequestEvent;
import javax.sip.message.Response;

/**
 * @author by HaiTao.Wang on 2025/9/15.
 */
@Slf4j
@Managed
public class ByeMessageProcessor extends SipRequestProcessorHandle implements SipMessageProcessor {

    @Init
    public void init() {
        SipProcessorContext.requestProcessor.put("BYE", this);
    }

    /**
     * 处理注册请求
     *
     * @param event 请求事件
     */
    @SneakyThrows
    @Override
    public void processRequest(RequestEvent event) {

        log.info("收到BYE请求");
        SIPRequest request = (SIPRequest) event.getRequest();
        response(request, Response.OK);

    }
}
